<?php
Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl."/css/common/css_menu/menu_accordion.css");
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/assets/javaScript/js_menu/menu_accordion.js',CClientScript::POS_BEGIN);


function category_multi_level($s_parent, $arr_data, $sprefix = "")
{
    $arr_temp = array();
    foreach ( $arr_data as $index => $o_category)
    {
        if( ($o_category instanceof Category) == true &&
            ($o_category->parent == $s_parent) )
        {
            array_push($arr_temp, $o_category);
        }//End if
    }//End foreach

    foreach ( $arr_temp as $index => $o_category)
    {
        $s_url = Yii::app()->createAbsoluteUrl( 
            "product/search",
            array( "urlMapping" => $o_category->url_mapping, 
                   "category"   => $o_category->identification,
                   "page"       => 1
            )
        );

        if( $o_category->child_count > 0 ) 
        {
            $s_activeClass = "class='active'";
            echo "<li ".$s_activeClass." ><a href='javascript:void(0);'>".$o_category->name."</a>";
        }
        else
        {
            echo "<li><a href='".$s_url."'>".$o_category->name."</a>";
        }

        if( $o_category->child_count > 0 )
            echo "<ul>";

        category_multi_level($o_category->identification, $arr_data,$sprefix."");

        if( $o_category->child_count > 0 )
            echo "</ul>";
        echo "</li>";
    }//End foreach
} 
?>
<div class="grid_232">
    <div class="box">
         <div class="header_ribbon">
         <div class="ribbon"><label>Danh Mục</label></div>
         <div class="triangle-l"></div>
         <div class="triangle-r"></div>
   </div>

    <ul class="menu_accordion">
        <?php
        if(isset($arr_category))
            category_multi_level( 0, $arr_category, $sprefix = "");
        ?>
    </ul>
</div>
</div>

<script type="text/javascript">
$(".menu_accordion").accordion({
    accordion:false,
    speed: 500,
    closedSign: '[+]',
    openedSign: '[-]'
});
</script>